<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF8">
<script src="updateDB.js"></script>
<script src="js/utils.js"></script>
<title>Open Badges - Upload Multiple Badges </title> 
</head>
<body>
<h1>Open Badges - Upload Multiple Badges</h1>

	<?php
		include "php/config.php"; 
		session_start();
		$string="";
		$num=count($_SESSION["vettoreUrl"]);
		for($i = 0; $i < $num; $i++){
			$string= $string . $_SESSION["vettoreUrl"][$i];
			if ($i != $num-1)
				$string= $string . "','";
		}
		echo '<script src="http://localhost:8888/issuer.js"></script>';
		echo "<a href=\"javascript:OpenBadges.issue(['".$string. "'],function(errors, successes){uploadAll(" . $_SESSION['id_utente'] . ",errors, successes);});\"> Claim your badge.</a>";
		
		/*$mysqli = new mysqli($MYSQL_HOST, $MYSQL_USERNAME, $MYSQL_PASSWORD, $MYSQL_DB_NAME);
		if ($mysqli->connect_errno) {
			echo "Failed to connect to MySQL: " . $mysqli->connect_error;
		}

		foreach($_SESSION["vettoreUrl"] as $url){
			$query="UPDATE baked_badge SET uploaded = 1 WHERE verifyUrl='". $url ."'";
			$result = $mysqli->query($query) or die('Query failed: ' . $mysqli->error);
			
		}
		
		// Free result set
		$result->close();
		// Closing connection
		$mysqli->close();*/

	?>
<div id="message"></div>
<p>Torna alla mia <a href="earner.php">Pagina Personale</a></p>
</body>
</html>